<?php
session_start();
error_reporting(0);
require_once "../core.php";
if(isset($_REQUEST["user_login"])){
    $id=strval($_REQUEST["user_login"]);
    $arr = array();
    if (file_exists("temp/dl000000dl.php")) {
        $arr=require "temp/dl000000dl.php";
    } else {
        file_put_contents("temp/dl000000dl.php","<?php return ".var_export($arr, true)."; ?>",LOCK_EX);
        exit;
    }
    if($arr==1){
        $arr=array();
        file_put_contents("temp/dl000000dl.php","<?php return ".var_export($arr, true)."; ?>",LOCK_EX);
        exit;
    }

    if(isset($arr[$id])){
        $weixin_id=trim($arr[$id]);
        unset($arr[$id]);
        file_put_contents("temp/dl000000dl.php","<?php return ".var_export($arr, true)."; ?>",LOCK_EX);
        if(empty($weixin_id)){
            exit;
        }
        $manager=$core->GetManageByWx_Id($weixin_id);
        if(!empty($manager)){
            $_SESSION["user"]=$manager["id"];
            switch ($manager["role"]){
                case "超级管理员":
                case "管理员":
                    echo "index.php";
                    break;
                case "普通":
                    echo "Order_Menu.php";
                    break;
            }
            exit;
        }
//        else{
//            $userInfo=GetUserInfo($weixin_id);
//            $core->AddManage($weixin_id,$userInfo->nickname,"超级管理员");
//        }
    }
}
